home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / zoo tutorial / module 6- advanced compositing / source / zoo6.java < prev    next >
Encoding:
Java Source  |  2000-06-23  |  4.5 KB  |  127 lines

  1. import java.awt.*;
  2. import java.awt.event.*;
  3.  
  4. import quicktime.QTSession;
  5. import quicktime.QTException;
  6.  
  7. import quicktime.app.image.GraphicsImporterDrawer;
  8. import quicktime.app.display.QTCanvas;
  9. import quicktime.app.QTFactory;
  10.  
  11. import quicktime.io.QTFile;
  12.  
  13.  
  14. /**
  15.  * QTZoo Module 6 - Event Processing and Custom UI
  16.  * This application requires QuickTime for Java
  17.  *
  18.  * @author Levi Brown
  19.  * @author Michael Hopkins
  20.  * @author Apple Computer, Inc.
  21.  * @version 4.1 11/15/1999
  22.  *
  23.  * Copyright:     © Copyright 1999 Apple Computer, Inc. All rights reserved.
  24.  *    
  25.  * Disclaimer:    IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  26.  *                ("Apple") in consideration of your agreement to the following terms, and your
  27.  *                use, installation, modification or redistribution of this Apple software
  28.  *                constitutes acceptance of these terms.  If you do not agree with these terms,
  29.  *                please do not use, install, modify or redistribute this Apple software.
  30.  *
  31.  *                In consideration of your agreement to abide by the following terms, and subject
  32.  *                to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  33.  *                copyrights in this original Apple software (the "Apple Software"), to use,
  34.  *                reproduce, modify and redistribute the Apple Software, with or without
  35.  *                modifications, in source and/or binary forms; provided that if you redistribute
  36.  *                the Apple Software in its entirety and without modifications, you must retain
  37.  *                this notice and the following text and disclaimers in all such redistributions of
  38.  *                the Apple Software.  Neither the name, trademarks, service marks or logos of
  39.  *                Apple Computer, Inc. may be used to endorse or promote products derived from the
  40.  *                Apple Software without specific prior written permission from Apple.  Except as
  41.  *                expressly stated in this notice, no other rights or licenses, express or implied,
  42.  *                are granted by Apple herein, including but not limited to any patent rights that
  43.  *                may be infringed by your derivative works or by other works in which the Apple
  44.  *                Software may be incorporated.
  45.  *
  46.  *                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  47.  *                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  48.  *                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  49.  *                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  50.  *                COMBINATION WITH YOUR PRODUCTS.
  51.  *
  52.  *                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  53.  *                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  54.  *                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55.  *                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  56.  *                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  57.  *                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  58.  *                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59.  * 
  60.  */
  61.  
  62. public class Zoo6 extends Frame
  63. {
  64.     static public int WIDTH  = 640;
  65.     static public int HEIGHT = 480;    
  66.     
  67.     /**
  68.      *  Zoo constructor
  69.      *  @param string title of window
  70.      */
  71.     public Zoo6( String s ) 
  72.     {
  73.         super(s);
  74.         setResizable( false );                        // we don't want the window to resize
  75.         setBounds( 0, 0, WIDTH, HEIGHT );            // make window 640x480
  76.         
  77.         QTCanvas myQTCanvas = new QTCanvas( QTCanvas.kInitialSize, 0.5F, 0.5F );
  78.         add( myQTCanvas );
  79.         
  80.         final AnimalPane zebraPane = new AnimalPane();    // load media
  81.         try
  82.         {
  83.             myQTCanvas.setClient( zebraPane.getCompositor(), true );
  84.  
  85.             zebraPane.start();
  86.         }
  87.         catch ( QTException e )
  88.         {
  89.             e.printStackTrace();
  90.         }
  91.                 
  92.         addWindowListener( new WindowAdapter()         // anonymous inner class for handling window events 
  93.         {
  94.             public void windowClosing( WindowEvent we )
  95.             {
  96.  
  97.                 zebraPane.stop();
  98.                 QTSession.close();                    // shut down QT and clean up
  99.                 dispose();                            // destroy window
  100.             }
  101.             public void windowClosed( WindowEvent we )
  102.             {
  103.                 System.exit( 0 );                    // exit to shell
  104.             }
  105.         });
  106.     }
  107.  
  108.     /**
  109.      * Main entry point for the application
  110.      */
  111.     public static void main (String[] args)
  112.     {
  113.         try
  114.         {
  115.             QTSession.open();                        // perform native QuickTime initialization
  116.             Zoo6 appWindow = new Zoo6( "QTZoo6" );    // create a new application window
  117.             appWindow.show();                        // make the window visible
  118.             appWindow.toFront();                    // bring it to the front
  119.         }
  120.         catch ( Exception e )                        // handle any exceptions
  121.         {
  122.             QTSession.close();
  123.             e.printStackTrace();
  124.         }
  125.     }    
  126. }
  127.